<template>
  <div id="home">
    <div class="layout"  :class="{'layout-hide-text': spanLeft < 4}">
      <Row type="flex" style="height: 100%;">
        <Col :span="spanLeft"  class="layout-menu-left">
        <Menu active-name="1" theme="dark" width="auto">
          <div class="layout-logo-left"></div>
          <router-link to="/manage">
            <MenuItem name="1">
              <Icon type="ios-navigate" :size="iconSize"></Icon>
              <span class="layout-text">
                欢迎页
              </span>
            </MenuItem>
          </router-link>
          <Submenu name="2">
            <template slot="title">
              <Icon type="ios-navigate" :size="iconSize"></Icon>
              <span class="layout-text">文章管理</span>
            </template>
            <router-link to="/artical">
              <MenuItem name="2-1">
                发布新文章
              </MenuItem>
            </router-link>
            <router-link to="/editArtical">
              <MenuItem name="2-2">修改文章</MenuItem>
            </router-link>
            <router-link to="/deleteArtical">
              <MenuItem name="2-3">删除文章</MenuItem>
            </router-link>
          </Submenu>
          <Submenu name="3">
            <template slot="title">
              <Icon type="ios-keypad" :size="iconSize"></Icon>
              <span class="layout-text">选项 3</span>
            </template>
            <MenuItem name="3-1">选项 1</MenuItem>
            <MenuItem name="3-2">选项 2</MenuItem>
          </Submenu>
          <Submenu name="4">
            <template slot="title">
              <Icon type="ios-analytics" :size="iconSize"></Icon>
              <span class="layout-text">个人信息</span>
            </template>
            <router-link to="/perInfo">
              <MenuItem name="4-1">个人信息</MenuItem>
            </router-link>
          </Submenu>
        </Menu>
        </Col>
        <Col :span="spanRight" class="contentRight">
        <div class="layout-header">
          <Button type="text" @click="toggleClick">
            <Icon type="navicon" size="32"></Icon>
          </Button>
        </div>
        <div class="layout-breadcrumb">
          <Breadcrumb>
            <BreadcrumbItem href="#">首页</BreadcrumbItem>
            <BreadcrumbItem href="#">应用中心</BreadcrumbItem>
            <BreadcrumbItem>某应用</BreadcrumbItem>
          </Breadcrumb>
        </div>
        <div class="layout-content">
          <router-view></router-view>
        </div>
        <div class="layout-copy">
          2011-2016 &copy; TalkingData
        </div>
        </Col>
      </Row>
    </div>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        spanLeft: 4,
        spanRight: 20
      }
    },
    computed: {
      iconSize () {
        return this.spanLeft === 4 ? 14 : 24;
      }
    },
    methods: {
      toggleClick () {
        if (this.spanLeft === 4) {
          this.spanLeft = 2;
          this.spanRight = 22;
        } else {
          this.spanLeft = 4;
          this.spanRight = 20;
        }
      }
    }
  }
</script>

<style scoped>
  * {
    margin: 0 auto;
    padding: 0;
  }

  #home {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #2c3e50;
    height:100%;
    position:fixed;
    width:100%;
  }
  .layout{
    border: 1px solid #d7dde4;
    background: #f5f7f9;
    position: relative;
    height:100%;
  }
  .layout-breadcrumb{
    padding: 10px 15px 0;
  }
  .layout-content{
    min-height: 200px;
    margin: 15px;
    overflow: hidden;
    background: #fff;
    border-radius: 4px;
  }
  .layout-content-main{
    padding: 10px;
  }
  .layout-copy{
    text-align: center;
    padding: 10px 0 20px;
    color: #9ea7b4;
  }
  .layout-menu-left{
    background: #464c5b;
  }
  .layout-header{
    height: 60px;
    background: #fff;
    box-shadow: 0 1px 1px rgba(0,0,0,.1);
  }
  .layout-hide-text .layout-text{
    display: none;
  }
  .layout-hide-text .ivu-menu-item{
    display: none;
  }
  .layout-hide-text .ivu-menu-submenu-title-icon{
    display: none !important;
  }
  .layout-logo-left{
    width: 90%;
    height: 30px;
    background: #5b6270;
    border-radius: 3px;
    margin: 15px auto;
  }
  .ivu-menu-item a{
    color: #ffffff;
  }
  .ivu-menu-item-active a{
    color: #2d8cf0;
  }
  .ivu-menu-item-selected a{
    color: #ffffff;
  }
  .contentRight{
    overflow-y: auto;
  }
</style>
